/**
 * 
 */
package com.longtop.framework.sys.flow.web;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.longtop.framework.base.BaseAction;
import com.longtop.framework.base.BaseService;
import com.longtop.framework.sys.flow.model.TSysFlowStep;
import com.longtop.framework.util.BeanUtil;
import com.longtop.framework.util.WebUtil;
import com.longtop.intelliweb.action.IInitContext;
import com.longtop.intelliweb.view.Dataset;

/**
 * @ 项目名 lzbank @ 类用途 @ 创建人 liaoqian @ 创建时间 2010-8-30 上午11:01:08 @ 修改人 @ 修改时间 @ 修改描述 @ 公司名称 东南融通 @ 当前系统主版本号
 */
public class FlowStepAction extends BaseAction {

	private final static String DATASET_INSTANCESTEP = "Dataset_FlowStep";

	/**
	 * JSP页面初始化方法
	 */
	public void init(IInitContext context) {
		super.init(context);

		// 获取页面上的dataset的结构,验证数据集对象是否存在
		Dataset stepDataset = (Dataset) context.getDataset(DATASET_INSTANCESTEP);
		if (!WebUtil.validateDatasetExist(this, stepDataset, DATASET_INSTANCESTEP)) {
			return;
		}

		BaseService baseService = this.getBean(BaseService.BEAN_ID);

		String instanceId = StringUtils.trimToEmpty(context.getRequest().getParameter("instanceId"));
		String isView = StringUtils.trimToEmpty(context.getRequest().getParameter("isView"));

		String hql = "";

		// 2010-09-27 胡砥峰提示： 客户要求显示全部步骤,原来代码注释
		// if("1".equals(isView))
		// hql = "from FlowStep where instanceId='" + instanceId + "' order by doTime asc";
		// else
		// hql = "from FlowStep where instanceId='" + instanceId + "' and status='1' order by doTime asc";
		hql = "from TSysFlowStep where instanceId='" + instanceId + "' order by doTime asc";

		List<TSysFlowStep> stepList = baseService.queryAll(hql);

		try {
			BeanUtil.listToDataset(stepList, stepDataset);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
